package cn.tedu.mvc;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//是MVC里的 C:控制器
@RestController()  //标记着这个类是Controller是一个控制器
@RequestMapping("car") //规定了URL怎么访问这个类
public class HelloController {
    @RequestMapping("get")  //规定了URL怎样访问这个方法
    public String show(){
        return "123";
    }
    @RequestMapping("abc")
    public int show2(){
        return 100;
    }
    /**SpringMVC框架除了能返回字符串,整数以外,还想返回对象信息
     * {
     *     {"id":718,"name":"保时捷","type":"Cayman T","color":"红色","price":641000.0}
     * }
     *
     */
    @RequestMapping("car")
    public Car car(){
        Car c = new Car();
        c.setColor("红色");
        c.setId(718);
        c.setName("保时捷");
        c.setType("Cayman T");
        c.setPrice(641000);
        return c;
    }
    @RequestMapping("arr")
    public String[] arr(){
        String[] arr = {"1","2","a","b"};
        return arr;
    }
}
